import time
from basic_基础信息.basic_requests import MerchantRequests
from basic_基础信息.config import Url

class MerchantSeckillProduct(MerchantRequests,Url):
    def merchant_seckill_product_page(self,auditstatus=None):
        params = {
            'page': '1',
            'limit': '20',
            'proName': '',
            'activityName': '',
            'auditStatus': auditstatus,     #1.待审核 2.审核成功 3.审核失败
            'activityStatus': '',
            'proStatus': '',
            'temp': '1758524729',
        }
        response = self.get(self.merchant_seckill_product_page.__name__,self.url_merchant_seckill_product_page,params)
        return response
    def merchant_seckill_product_add(self,id=None,productList_id=None):

        json_data = {
            'id': id,                       #秒杀活动id
            'productList': [
                {
                    'id': productList_id,   #商品id
                    'sort': 0,
                    'attrValue': [
                        {
                            'activityPrice': 0.01,
                            'attrValueId': 16752,
                            'quota': 10,
                        },
                    ],
                },
            ],
        }

        response = self.post(self.merchant_seckill_product_add.__name__,self.url_merchant_seckill_product_add,json_data)
        return response
    def merchant_seckill_product_withdraw(self,id=None):
        response = self.post(self.merchant_seckill_product_withdraw.__name__,self.url_merchant_seckill_product_withdraw+f'/{id}')#秒杀活动-秒杀商品撤回接口
        return response
    def merchant_seckill_product_delete(self,ids=None):
        json_data = {'ids': ids}
        response = self.post(self.merchant_seckill_product_delete.__name__,self.url_merchant_seckill_product_delete,json_data)#秒杀活动-秒杀商品删除接口
        return response
    def merchant_seckill_activity_list(self, page=1, limit=20, name=None, date=None, temp=str(int(time.time()))):
        params = {
            'page': str(page),
            'limit': str(limit),
            'name': name,
            'date': date,
            'temp': temp,
        }
        response = self.get(self.merchant_seckill_activity_list.__name__,self.url_merchant_seckill_activity_page,params)
        return response

if __name__ == '__main__':
    MerchantSeckillProduct().merchant_seckill_product_page(auditstatus=2)
    MerchantSeckillProduct().merchant_seckill_product_add(id=80)
    MerchantSeckillProduct().merchant_seckill_product_withdraw(id=557)
    MerchantSeckillProduct().merchant_seckill_product_delete(ids=557)
    MerchantSeckillProduct().merchant_seckill_activity_list()